<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .carowner_1,.carowner_2{display: block;margin-top: 10px;width:100%;height:26px;}
    .carowner_2{margin-left:0px;}
    .select_model{
        -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img3.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 115px 5px;
        border: 1px solid #d7d7d7; color:#7f7f7f;float: left;height: 26px;line-height: 26px;margin-right: 8px;text-indent: 2px;width: 136px;}
    .search_btn{height:26px;line-height:26px;
                background: #20ab4f none repeat scroll 0 0;border-radius: 3px;border:medium none;color: #fff;
                margin-left: 7px;padding: 0;width: 60px;float:left;margin-left: 10px;}
    .bidding_time{float:left;}
    #bidding_start_time,#bidding_end_time{border: 1px solid #d7d7d7;height: 24px;line-height: 24px;margin:0 5px;text-align: center;width: 150px;}
    .source_input{margin:0 10px;}
    .yuList .listBox table{margin-top: 10px;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="cxtj.mcyhcx" />
    <div class="mianR">
      <div class='carowner_1'>
            <div class="bidding_time">
                从<input type="text" name="start_time" placeholder="请选择提交时间" value="" class="xiaci xin-text1" id="bidding_start_time" readonly>
                到<input type="text" name="end_time"  placeholder="请选择提交时间" value="" class="xiaci xin-text1" id="bidding_end_time" readonly />
            </div>
            <!--<script src="{:get_style_cdnurl()}paimai/cheshan/js/model_select.js" type="text/javascript"></script>-->
            <input type="text" name="car_model" id="car_model" value="" placeholder="请输入车型名称" style="border: 1px solid #d7d7d7;float: left;height: 24px;line-height: 24px;margin-right:15px;text-align: center;width: 160px;">
            <select id="location_area" name="location_area" class="select_model">
                <if condition="count($bc_city) gt 1">
                    <option value="0">请选择所在地</option>
                </if>
                <volist name="bc_city" id="city">
                    <option value="{$key}">{$city}</option>
                </volist>
            </select>

            <select name="order_status" id="order_status" class="select_model">
                <option value="0">请选择业务状态</option>
                <option value="1">待预约</option>
                <option value="2">跟踪预约</option>
                <option value="4">待分配</option>
                <option value="7">待检测</option>
                <option value="3">预约失败</option>
                <option value="5">检测成功</option>
                <option value="6">检测失败</option>
            </select>

        </div>
        <div class='carowner_2'>
            <input type="text" id="seller_name" name="car_owner_name" value="" placeholder="车主姓名" style="border: 1px solid #d7d7d7;float: left;height: 24px;line-height: 24px;margin-left:15px;text-align: center;width: 150px;"/>
            <select name="server_id" id="server" style="width:162px;float:left;margin-left:16px;">
                <option value=''>请选择客服</option>
                <volist name='server' id='se'>
                    <option value="{$se.emp_id}">{$se.real_name}</option>
                </volist>
            </select>

            <select name="branch_company" id="branch_company" class="branch_company select_model" style="margin:0 0 0 10px;">
                <if condition="$branch_id eq 0">
                    <option value="0">评估师所属分公司</option>
                </if>
                <foreach name="bc_list" item="vo" key="k">
                    <option value="{$k}" <?=$k == $branch_id ? 'selected' : ''?> >{$vo}</option>
                </foreach>
            </select>

            <select name="checker_id" id="checker" style="width:162px;float:left;margin-left:10px;">
                <option value=''>请选择评估师</option>
                <volist name='checker' id='ce'>
                    <option value="{$ce.emp_id}">{$ce.real_name}</option>
                </volist>
            </select>	
            <!--<select id="from" name="from" class="select_model" style='margin-left:17px;'>-->
                <!--<option value="0">请选择渠道来源</option>-->
                <!--<?php foreach($pfrom as $item):?>-->
                <!--<option value="{$item.from_id}">{$item.from_name}</option>-->
                <!--<?php endforeach;?>-->
            <!--</select>-->

            <!--<select id="comeFrom" name="comefrom" class="select_model" style='margin-left:5px;'>-->
                <!--<option value="-2">请选择具体来源</option>-->
            <!--</select>-->
            <div class="source_input">
                <input type="text"  name="comefrom" value="" placeholder="请选择渠道来源" readOnly />
                <div class="source">
                    <ul>
                        <?php foreach($pfrom as $item):?>
                        <li date="{$item.from_id}">{$item.from_name}</li>
                        <?php endforeach;?>
                    </ul>
                </div>
                <div class="sourceCity">
                    <ul>
                        <foreach name="bc_city" item="vo" key="k">
                            <li date-city="{$k}">{$vo}</li>
                        </foreach>
                    </ul>
                </div>
                <div class="sourceTab">
                    <foreach name="comefrom_list" item="cl" key="k">
                        <div class="sourceList" date-pid="{$k}">
                            <ul>
                                <foreach name="cl" item="clv">
                                    <li date-id="{$clv.from_id}">{$clv.from_name}</li>
                                </foreach>
                            </ul>
                        </div>
                    </foreach>

                    <div class="sourceList siSdian">
                        <foreach name="city_fours_list" item="cfl" key="k">
                            <ul style="display: none;" date-code-city="{$k}">
                                <foreach name="cfl" item="cflv">
                                    <li date-id="{$cflv.from_id}">{$cflv.from_name}</li>
                                </foreach>
                            </ul>
                        </foreach>
                    </div>
                </div>
            </div>

            <input type="button" id="search" value="搜索" class="search_btn">
            <div class='clear'></div>
        </div>
        <div class="yuList">
            <div class="listBox" id="listBox"></div>
        </div>
    </div>
    <div id="showOptionChecker" style="display:none">
        <volist name="checker" id="vo">
            <option class="{$vo['branch_id']}" value="{$vo['emp_id']}" >{$vo['real_name']}</option>
        </volist>
    </div>

    <!--<div id="showOption" style="display:none">-->
    <!--<volist name="from" id="vo">-->
    <!--<option class="{$vo['pid']}" value="{$vo['from_id']}" >{$vo['from_name']}</option>-->
    <!--</volist>-->
    <!--</div>-->

    <div class="clear"></div>
    <include file="Public/foot" />

    <script type="text/javascript">
        $(".branch_company").change(function(){
            $("#select2-chosen-2").html('请选择评估师');
        });
        $("body,html").click(function(event) {
            $(".sourceCity").hide();
            $(".sourceTab .sourceList").hide();
            $(".source").hide();
            event.stopPropagation();
        });

        $(".source_input").click(function(event) {
            event.stopPropagation();
        });
        $(".source_input input").val("");
        $(".source_input input").click(function() {
//            $(this).val("");
            if($(".source").css("display")=="none"){
                $(".source").fadeIn();
            }else{
                $(".source").hide();
            }
            $(".sourceCity").hide();
            $(".sourceTab .sourceList").hide();
        });
        var index;
        var text;
        var dateIndex;
        $(".source ul li").click(function() {
            index=$(".source ul li").index(this);
            text=$(this).html();
            dateIndex=$(this).attr("date");
            if(dateIndex==5){
                $(".sourceCity").fadeIn();
                $(".sourceTab .sourceList").hide();
            }else{
                $(".sourceCity").hide();
                $(".sourceTab .sourceList[date-pid='"+dateIndex+"']").fadeIn().siblings().hide();
            }
            $(this).parent().parent().hide();
        });
        var city;
        var cityIndex;
        $(".sourceCity ul li").click(function(i){
            city=$(this).html();
            $(this).parent().parent().hide();
            cityIndex=$(this).attr("date-city");
            $(".sourceTab .siSdian").fadeIn().find("ul[date-code-city='"+cityIndex+"']").fadeIn().siblings().hide();
        })
        $(".sourceList ul li").click(function(){
            $(this).parent().parent().hide();
            if(index==3){
                $(".source_input input").val(text+" - "+city+" - "+$(this).html());
                $(".source_input input").attr("real-value",$(this).attr("date-id"));
            }else{
                $(".source_input input").val(text+" - "+$(this).html());
                $(".source_input input").attr("real-value",$(this).attr("date-id"));
            }
        });





        $("#bidding_start_time").ymdateplugin({});
        $("#bidding_end_time").ymdateplugin({});
        $("#server,#checker").select2();
        $(function () {
            $(".cheXiaCo1").hide();
            $(".chexing").css("width", "345px");
            $(".chexing span").hide();
        });

        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null)
                return unescape(r[2]);
            return null; //返回参数值
        }
        get_list();
        function get_list(isSearch) {
            var url = get_url();
            var purl = '';
            if (isSearch != 1) {
                var p = getUrlParam('p');
                if (p != null) {
                    purl = "?p=" + p;
                } else {
                    purl = "?p=1";
                }
            }
            $.get("/CarOwnerCheck/car_owner_list" + purl, encodeURI(url), function (data) {
                $("#listBox").html(data);
            }, "html");
        }

        function get_page(p) {
            var url = get_url();
            url += "&p=" + p;
            $.get("/CarOwnerCheck/car_owner_list", encodeURI(url), function (data) {
                $("#listBox").html(data);
            }, "html");
        }
        $(".search_btn").on("click", function () {
            var isSearch = 1;
            get_list(isSearch);
        });
        function get_url() {
            var url = "";
            var start_time = $("input[name='start_time']").val();
            var end_time = $("input[name='end_time']").val();
            var car_model = $("#car_model").val();
//            var brand_id = $('.pingXiaCo').attr('brand_id');
//            var series_id = $('.cheXiaCo').attr('series_id');
            var location_area = $("#location_area").val();
            var status = $("#order_status").val();
            var seller_name = $("#seller_name").val();
            var server = $("#server").val();
            var checker = $("#checker").val();
            var comefrom = $("input[name='comefrom']").attr('real-value');

            if (start_time) {
                url += '&start_time=' + start_time;
            }
            if (end_time) {
                url += '&end_time=' + end_time;
            }
            if (car_model) {
                url += '&car_model=' + car_model;
            }
//            if (brand_id) {
//                url += '&brand_id=' + brand_id;
//            }
//            if (series_id) {
//                url += '&series_id=' + series_id;
//            }
            if (location_area) {
                url += '&location_area=' + location_area;
            }
            if (status) {
                url += '&status=' + status;
            }
            if (seller_name) {
                url += '&seller_name=' + seller_name;
            }
            if (server) {
                url += '&server=' + server;
            }
            if (checker) {
                url += '&checker=' + checker;
            }
            if (comefrom) {
                url += '&comefrom=' + comefrom;
            }
            return url;
        }
        $("#from").change(function () {
            var value = $(this).val(); //获取渠道当前下拉列表选中的值
            //隐藏所有下拉列表的值
            $("#comeFrom option").each(function () {
                if ($(this).val() != '') {
                    $(this).remove();
                }
            });

            //显示具体渠道下拉列表
            $("#showOption option").each(function () {
                if ($(this).val() == '' || $(this).attr("class") == value) { //通过判断class名称判断是否显示
                    $("#comeFrom").append($(this).clone(true)); //为Select追加一个Option(下拉项)
                    if ($(this).val() == '') {
                        $(this).prop("selected", true)
                    }
                }
            });

        });
        $('.branch_company').change(function(){
            var bc_value = $(this).val(); //获取渠道当前下拉列表选中的值
            //隐藏所有下拉列表的值
            $("#checker option").each(function(){
                if($(this).val()!='0'){
                    $(this).remove();
                }
            });
            //显示具体渠道下拉列表
            $("#checker").empty()
                    .append('<option value="0" style="color: rgb(0, 0, 0);">请选择评估师</option>')
                    .append($("#showOptionChecker ." + bc_value).clone());
        });
        //初始化分公司下的评估师列表
        init_checker_list();
        function init_checker_list(){
            var branch_obj = $('.branch_company');
            var branch_id = branch_obj.val();
            //显示具体渠道下拉列表
            $("#checker").empty()
                    .append('<option value="0" style="color: rgb(0, 0, 0);">请选择评估师</option>')
                    .append($("#showOptionChecker ."+branch_id).clone());
        }


        $("#start_time").ymdateplugin({
            changeMonth: true,
            changeYear: true
        });

        $("#end_time").ymdateplugin({
            changeMonth: true,
            changeYear: true
        });
    </script>